#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

int main()
{
    //int fd = open("log.txt", O_CREAT|O_WRONLY|O_TRUNC,0666);
    //int fd = open("log.txt", O_CREAT|O_WRONLY|O_APPEND,0666);
    int fd = open("log.txt", O_RDONLY);
    
    dup2(fd,0);

    while(1)
    {
        char buffer[64];
        fgets(buffer,sizeof(buffer),stdin);

        printf("%s",buffer);
        sleep(1);
    }

    //printf("Hello\n");
    //printf("Hello\n");
    //printf("Hello\n");
    //printf("Hello\n");

    //fprintf(stdout,"Hello stdout\n");
    //fprintf(stdout,"Hello stdout\n");
    //fprintf(stdout,"Hello stdout\n");
    //fprintf(stdout,"Hello stdout\n");

    //const char* msg = "Hello World\n";
    //write(fd,msg,strlen(msg));
    return 0;
}
